<?php

	class source {

		var $fw		= null;
		var $sec	= null;

		function source(&$framework, &$security)
		{

			$this->fw	= &$framework;
			$this->sec	= &$security;

			$this->fw->js[] = 'welcome.js';

			switch($this->fw->do)
			{

				case 'feedback':
					$this->feedback();
					break;

				case 'logout':
					$this->sec->distroy_authentication();
					header('location: index.php');
					exit;
					break;

				default:
					$this->show_welcome();
					break;

			}

		}

		function feedback()
		{
			$feedback	= $_POST['feedback'];
			mail('ben.rowe.83@gmail.com', 'Movie Manager: Feedback', $feedback);
			$_SESSION['msg'] = 'Feedback successfully sent';
			header('location: index.php');
			exit;
		}

		function show_welcome()
		{

			$this->fw->template = 'welcome.data.tpl';

			$member_id	= $this->sec->dtls['id'];
			$movies		= $this->fw->get_movies_recent(30);

			$this->fw->content['recent']	= $movies;

			$this->fw->content['wishlist']	= $this->fw->get_wishlist_available();

			// borrow requests
			$this->fw->content['borrow_requests'] = $this->fw->get_request_borrow($member_id);
			$this->fw->content['borrow_requests2'] = $this->fw->get_request_borrow($member_id);

			// borrowed
			$this->fw->content['borrowed']	= $this->fw->get_borrowed($member_id);

			// borrowing
			$this->fw->content['borrowing']	= $this->fw->get_borrowing($member_id);

		}

	}

?>
